import { config } from '../../config/index';
import util from "../../utils/util.js"
/** 获取商品列表 */
function mockFetchGood(ID = 0) {
	const { delay } = require('../_utils/delay');
	const { genGood } = require('../../model/good');
	return delay().then(() => genGood(ID));
}

/** 获取商品列表 */
export function fetchGood(ID = 0) {
	if (config.useMock) {
		return mockFetchGood(ID);
	}
	return new Promise((resolve) => {
		resolve('real api');
	});
}
/** 获取商品详情 */
export function GoodsDetail(params) {
	return util.request({
		url: "/goods/detail",
		method: 'get',
		params,
	})
}
/** 加入购物车 */
export function AddCard(params) {
	return util.request({
		url: "/goods/cart/add",
		method: 'post',
		params,
	})
}